<ui:composition
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui"
        xmlns:jsf="http://xmlns.jcp.org/jsf"
        xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
        xmlns:ezcomp="http://xmlns.jcp.org/jsf/composite/ezcomp">

    <script>
        $(function () {
            var Height = (document.documentElement.clientHeight || document.body.clientHeight) + 175;
            document.getElementById("maintab:fydslist:fydDemoLists").style.height = Height - 400 + "px";
        });
        window.onresize = function () {
            var Height = (document.documentElement.clientHeight || document.body.clientHeight) + 175;
            document.getElementById("maintab:fydslist:fydDemoLists").style.height = Height - 1000 + "px";
        };
    </script>
    <script language="JavaScript" type="text/javascript">
        function clearNoNum(obj) {
            obj.value = obj.value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
            obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
            obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
        }
    </script>
    <h:form id="fydlist">
        <p:panel id="fydslist" style="height: 40px;font-weight: bolder;font-size: 20px;text-align: center ">
            <span>费用单</span>
        </p:panel>
        <p:menubar id="menu">
            <f:facet name="options">
                <p:commandButton value="查询" icon="fa fa-search" disabled="#{kzbd.bb('fyd-demo').mc.anniu['查询']}"
                                 action="#{kzbd.bb('fyd-demo').mc.select()}"
                                 process="@this,fyd-demoHeader" update="msg,menu,fyd-demoHeader,zh,sh"/>
                <p:commandButton value="新增" icon="fa fa-plus-square" disabled="#{kzbd.bb('fyd-demo').mc.anniu['新增']}"
                                 action="#{kzbd.bb('fyd-demo').mc.start()}"
                                 process="@this,fyd-demoHeader" update="msg,fyd-demoHeader,menu,zh,sh,"/>
                <p:commandButton value="修改" icon="fa fa-edit" disabled="#{kzbd.bb('fyd-demo').mc.anniu['修改']}"
                                 action="#{kzbd.bb('fyd-demo').mc.update()}"
                                 process="@this,fyd-demoHeader" update="msg,fyd-demoHeader,menu,zh,sh"/>
                <p:commandButton value="删除" icon="fa fa-backspace" disabled="#{kzbd.bb('fyd-demo').mc.anniu['删除']}"
                                 action="#{kzbd.bb('fyd-demo').mc.delete()}"
                                 process="@this,fyd-demoHeader" update="msg,fyd-demoHeader,menu,zh,sh"/>
                <p:commandButton value="保存" icon="fa fa-save" disabled="#{kzbd.bb('fyd-demo').mc.anniu['保存']}"
                                 action="#{kzbd.bb('fyd-demo').mc.insert()}"
                                 process="@this,fyd-demoHeader,feiyongdanList" update="msg,fyd-demoHeader,menu,feiyongdanList,zh,sh"/>
                <p:commandButton value="取消" icon="fa fa-cancel" disabled="#{kzbd.bb('fyd-demo').mc.anniu['取消']}"
                                 action="#{kzbd.bb('fyd-demo').mc.cancel()}"
                                 process="@this,fyd-demoHeader" update="msg,menu,fyd-demoHeader,zh,sh"/>
            </f:facet>
        </p:menubar>
        <p:panel id="fyd-demoHeader" style=" height: 160px;width: 100%">
            <h:panelGrid columns="8" cellpadding="8" style="width: 100%">
                <p:outputLabel value="单据编号" style="width: 100%"/>
                <p:inputText readonly="#{kzbd.bb('fyd-demo').mc.start}" value='#{kzbd.bb("fyd-demo").mc.datalist["invoice_number"]}'
                             style="width: 100%"/>

                <p:outputLabel value="报销类型" style="width: 100%">
                    <h:outputText style="color: red; size: 10px" value="*"/>
                </p:outputLabel>
                <p:selectOneMenu readonly="#{!kzbd.bb('fyd-demo').mc.save}"
                                 value='#{kzbd.bb("fyd-demo").mc.datalist["invoice_type"]}'
                                 id="ReimbursementType" style="width: 100%">
                    <f:selectItem itemLabel="请选择" itemValue="0"/>
                    <f:selectItem itemLabel="公共费用" itemValue="1"/>
                    <f:selectItem itemLabel="项目费用" itemValue="2"/>
                    <f:selectItem itemLabel="客户费用" itemValue="3"/>
                    <f:selectItem itemLabel="合同前费用" itemValue="4"/>
                </p:selectOneMenu>

                <p:outputLabel value="合同编号" style="width: 100%"/>
                <p:inputText readonly="false"
                             value='#{kzbd.bb("fyd-demo").mc.datalist["contract_number"]}'
                             style="width: 100%"/>

                <p:outputLabel value="客户名称" style="width: 100%"/>
                <p:inputText readonly="false"
                             value='#{kzbd.bb("fyd-demo").mc.datalist["client_name"]}'
                             style="width: 100%"/>

                <h:outputLabel value="单据状态" style="width: 100%">
                    <h:outputText style="color: red; size: 10px" value="*"/>
                </h:outputLabel>
                <p:selectOneMenu readonly="#{!kzbd.bb('fyd-demo').mc.save}"
                                 value='#{kzbd.bb("fyd-demo").mc.datalist["invoice_status"]}'
                                 disabled="false" style="width:100%">
                    <f:selectItem itemLabel="" itemValue=""/>
                    <f:selectItem itemLabel="提交" itemValue="1"/>
                    <f:selectItem itemLabel="审批中" itemValue="2"/>
                    <f:selectItem itemLabel="生效" itemValue="3"/>
                    <f:selectItem itemLabel="驳回" itemValue="4"/>
                    <f:selectItem itemLabel="已删除" itemValue="5"/>
                    <f:selectItem itemLabel="开立" itemValue="6"/>
                </p:selectOneMenu>

                <p:outputLabel value="费用总金额" style="width: 100%"/>
                <p:inputNumber id="hkje" value='#{kzbd.bb("fyd-demo").mc.datalist["money_all"]}' readonly="true"
                               decimalPlaces="2" nmouseover="this.title = this.value" inputStyle="width:100%"/>

                <p:outputLabel value="提报人" style="width: 100%">
                    <h:outputText style="color: red; size: 10px" value="*"/>
                </p:outputLabel>
                <p:inputText readonly="#{!kzbd.bb('fyd-demo').mc.save}"
                             value='#{kzbd.bb("fyd-demo").mc.datalist["reporter"]}'
                             style="width: 100%"/>

                <p:outputLabel value="提报部门" style="width: 100%">
                    <h:outputText style="color: red; size: 10px" value="*"/>
                </p:outputLabel>
                <p:inputText readonly="#{!kzbd.bb('fyd-demo').mc.save}"
                             value='#{kzbd.bb("fyd-demo").mc.datalist["department"]}'
                             style="width: 100%"/>

                <p:outputLabel value="提报时间" style="width: 100%">
                    <h:outputText style="color: red; size: 10px" value="*"/>
                </p:outputLabel>
                <p:datePicker pattern="yyyy-MM-dd" monthNavigator="true" yearNavigator="true"
                              inputStyle="width:100%" styleClass="inputStylewidth" readonly="true"
                              value='#{kzbd.bb("fyd-demo").mc.datalist["report_time"]}'/>

                <p:outputLabel value="审核人"/>
                <p:inputText readonly="#{!kzbd.bb('fyd-demo').mc.save}"
                             value='#{kzbd.bb("fyd-demo").mc.datalist["auditor"]}'
                             style="width:100%"/>
                <p:outputLabel value="审核时间"/>
                <p:inputText value='#{kzbd.bb("fyd-demo").mc.datalist["audit_time"]}'
                             readonly="#{!kzbd.bb('fyd-demo').mc.save}" style="width:100%"/>
            </h:panelGrid>
        </p:panel>
        <p:panel id="fyd-demoListHeader" style="width: 100%;text-align: left ">
            <f:facet name="header">
                <p:commandButton value="增行" id="zh" disabled="#{kzbd.bb('fyd-demo').mc.anniu['增行']}"
                                 action="#{kzbd.bb('fyd-demo').mc.add()}" process="@this,feiyongdanList"
                                 update="msg,feiyongdanList" />
                <p:commandButton value="删行" id="sh" disabled="#{kzbd.bb('fyd-demo').mc.anniu['删行']}"
                                 action="#{kzbd.bb('fyd-demo').mc.remove()}" process="@this,feiyongdanList"
                                 update="msg,feiyongdanList" />
            </f:facet>
        </p:panel>
        <div id="fydDemoLists" style="height: 640px;position: relative;overflow: hidden">
            <!-- 数据表 -->
            <p:dataTable emptyMessage="无记录" id="feiyongdanList" var="li"
                         showGridlines="true" selectionMode="multiple" selection="#{kzbd.bb('fyd-demo').mc.itemtabxz}"
                         stripedRows="true" resizableColumns="true" reflow="true"
                         value="#{kzbd.bb('fyd-demo').mc.itemlist}" rowKey="#{li.id}"
                         paginatorTemplate="{CurrentPageReport} {inputpagenumber} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         currentPageReportTemplate="(行: {startRecord} - {endRecord} of {totalRecords}, 页: {currentPage}/{totalPages})"
                         rowsPerPageTemplate="50,100,150,200"
                         rowSelectMode="add" paginatorPosition="bottom" >
                <!-- 添加复选框 -->
                <p:column selectionMode="multiple" exportable="false" style="box-sizing: content-box;width:15px"/>
                <!-- 费用类型列 -->
                <p:column headerText="费用类型" sortBy="#{li.money_type}"
                          style="width: 100px;text-align:center" sortable="true">
                    <p:selectOneMenu id="ReimbursementType" value="#{li.money_type}" style="width: 100%">
                        <f:selectItem itemLabel="请选择" itemValue="0"/>
                        <f:selectItem itemLabel="差旅费" itemValue="1"/>
                        <f:selectItem itemLabel="住宿费" itemValue="2"/>
                        <f:selectItem itemLabel="办公用品费" itemValue="3"/>
                        <f:selectItem itemLabel="招待费" itemValue="4"/>
                    </p:selectOneMenu>
                </p:column>
                <!-- 金额列 -->
                <p:column headerText="金额" sortBy="#{li.money}"
                          style="box-sizing: content-box;width: 100px;text-align:center" sortable="true">
                    <h:outputText style="color: red; size: 100px" value="*"/>
                    <p:inputNumber value="#{li.money}" readonly="#{!kzbd.bb('fyd-demo').mc.save}" style="width: 100%;text-align: center"
                                   onmouseover="this.title = this.value" decimalPlaces="2" inputStyle="width:100px">
                        <p:ajax event="change" listener="#{kzbd.bb('fyd-demo').mc.gb()}"
                                update="msg,maintab:fydlist:hkje" process="@this,feiyongdanList"/>
                    </p:inputNumber>
                </p:column>

                <!-- 用途列 -->
                <p:column headerText="用途" sortBy="#{li.yongtu}" style="width: 400px;text-align:center" sortable="true">
                    <p:inputText value="#{li.yongtu}" style="width: 100%;text-align: left"/>
                </p:column>
                <!-- 备注列 -->
                <p:column headerText="备注" sortBy="#{li.PS}" style="width: 400px;text-align:center" sortable="true">
                    <p:inputText value="#{li.PS}" style="width: 100%;text-align: left"/>
                </p:column>
            </p:dataTable>
        </div>
    </h:form>
</ui:composition>